<template>
  <div class="header" :style="{background:bgColor}">
    <span class="homeBtn" @click="toHome" :style="{background:btnColor}">首页</span>
    <h3 class="title">
      <slot name="title">默认值</slot>
    </h3>
  </div>
</template>

<script>
export default {
  methods: {
    toHome() {
      this.$router.push('/');
    }
  },
  props: ['bgColor', 'btnColor']
};
</script>

<style  scoped>
.header {
  background: #2f3542;
  position: fixed;
  top: 0;
  width: 100%;
  height: 1.2rem;
  line-height: 1.2rem;
  
  border-radius: 0 0 0.1rem 0.1rem;
}
.homeBtn {
  width: 1rem;
  height: 0.5rem;
  color: #2f3542;
  margin: 0.25rem 0.2rem;
  padding: 0.1rem;
  background: #ced6e0;
  border-radius: 1rem;
  text-align: center;
  line-height: 0.5rem;
  box-shadow: 0.02rem 0.02rem rgba(255, 255, 255, 0.5);
}

.title {
  color: #fff;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: bolder;
}
</style>